/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com 

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TRI_TIMER_H_
#define TRI_TIMER_H_

#include <stdlib.h>
#include <time.h>

namespace tri{

/**
 * TIMER MODES
 */
enum ProgressTimerSetting{
	CLOCK_TYPE = 0,
	TIMER_TYPE
};

class TProgressTimer{
	
public:
    TProgressTimer();
    virtual ~TProgressTimer();
    
    /**
     * reset the timer.
     */
    void reset();
    
    /**
     * Start the timer
     */
    bool start();
    
    /**
     * Stop the timer
     */
    void stop();
    
    
    /**
     * Get the elapsed time since start() was called
     * in seconds.
     */
    double getElapsedTime();
    
    /**
     * Get how far along the timer is since
     * reset was called. Inicated by a value from 0.0 -> 1.0.
     * 1.0 being completion
     */
    double getProgress();
    
    /**
     * Is the timer still running.
     */
    bool isRunning();
    
    /**
     * Set the timer size in seconds
     */
    void setDurationTime(double t);    
    
    /**
     * Set timer running mode
     * CLOCK_MODE or TIMER_MODE
     */
    void setMode(ProgressTimerSetting mode);
    
    /**
     * Get current running mode 
     */
    ProgressTimerSetting getMode();
    
private:
    time_t m_StartTime;
    double m_Duration;
    time_t m_EndTime;
    ProgressTimerSetting m_Mode;
};

}

#endif /*TIMER_H_*/
